package com.kevin.ejb3;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.*;

/**
 * Created by loli on 2015/3/15.
 */
@Stateful
@Remote({LifeCycle.class})
public class LifeCycleBean implements LifeCycle {
    public String say() {
        try {
            Thread.sleep(1000 * 10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "test the lifecycle of session bean";
    }

    @Init
    public void init() {
        System.out.println("init the session bean");
    }

    @PostConstruct
    public void construct(){
        System.out.println("construct the session bean");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("destroy the session bean");
    }

    @PrePassivate
    public void passivate(){
        System.out.println("passivate the session bean");
    }

    @PostActivate
    public void activate(){
        System.out.println("activate the session bean");
    }
}
